package com.magiccompass.alipay.barcode.entity;

import java.math.BigDecimal;
import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

import com.magiccompass.alipay.barcode.model.AlipayBarcodeBaseRequest;
import com.magiccompass.alipay.barcode.util.DateTimeUtil;

@Entity
@Table(name = "TD_ALIPAY_BARCODE_PAYMENT_REQUEST")
@DynamicUpdate(value= true)
public class AlipayBarcodePaymentRequest extends AlipayBarcodeBaseRequest {
	@Id
	@Column(name = "ID")
	@GeneratedValue
	private Integer id;
	
	@OneToOne(cascade=CascadeType.ALL,fetch= FetchType.EAGER)
	@JoinColumn(name="merchant_transaction_id", nullable=false, unique=true)
	private MerchantTransaction merchantTransaction;
	
	@ManyToOne(cascade=CascadeType.REFRESH,fetch= FetchType.EAGER)
	@JoinColumn(name="merchant_id", nullable=false)
	private MerchantInfo merchant;
	
	@Column(name = "status",length=1, nullable=false)
	private String status="I"; // I:initial; S:success; F:failed; U:unknown; R:reversed; C:cancelled; D: deleted; E:refunded
	
	@Column(name = "sign",length=512, nullable=true)
	private String sign;
	
	@Column(name = "trans_name",length=512, nullable=false)
	private String transName="";
	
	@Column(name = "currency",length=3, nullable=false)
	private String currency="NZD";
	
	@Column(name = "total_amount", nullable=false,precision=12, scale=2)
	private BigDecimal totalAmount;
	
	@Column(name = "buyer_identity_code",length=32, nullable=true)
	private String buyerIdentityCode;
	
	@Column(name = "identity_code_type",length=16, nullable=true)
	private String identityCodeType;
	
	@Column(name = "finalized_time", nullable=true)
	private Timestamp finalizedTime;
    
	@Column(name = "create_by", nullable=false)
	private Integer createBy;
	
	@Column(name = "create_time", nullable=false)
	private Timestamp createTime = DateTimeUtil.getCurrentTimestamp();

	@Column(name = "update_by")
	private Integer updateby;

	@Column(name = "update_time")
	private Timestamp updateTime;
	
	@Column(name = "del_flag")
	private String delFlag = "F";
	
	@Column(name = "extend_info",length=512, nullable=true)
	private String extendInfo;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	public Integer getCreateBy() {
		return createBy;
	}
	public void setCreateBy(Integer createBy) {
		this.createBy = createBy;
	}
	public Timestamp getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}
	public Integer getUpdateby() {
		return updateby;
	}
	public void setUpdateby(Integer updateby) {
		this.updateby = updateby;
	}
	public String getDelFlag() {
		return delFlag;
	}
	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}
	public MerchantTransaction getMerchantTransaction() {
		return merchantTransaction;
	}
	public void setMerchantTransaction(MerchantTransaction merchantTransaction) {
		this.merchantTransaction = merchantTransaction;
	}
	public MerchantInfo getMerchant() {
		return merchant;
	}
	public void setMerchant(MerchantInfo merchant) {
		this.merchant = merchant;
	}
	public String getSign() {
		return sign;
	}
	public void setSign(String sign) {
		this.sign = sign;
	}
	public String getTransName() {
		return transName;
	}
	public void setTransName(String transName) {
		this.transName = transName;
	}
	public String getCurrency() {
		return currency;
	}
	public void setCurrency(String currency) {
		this.currency = currency;
	}
	public BigDecimal getTotalAmount() {
		return totalAmount;
	}
	public void setTotalAmount(BigDecimal totalAmount) {
		this.totalAmount = totalAmount;
	}
	public String getBuyerIdentityCode() {
		return buyerIdentityCode;
	}
	public void setBuyerIdentityCode(String buyerIdentityCode) {
		this.buyerIdentityCode = buyerIdentityCode;
	}
	public String getIdentityCodeType() {
		return identityCodeType;
	}
	public void setIdentityCodeType(String identityCodeType) {
		this.identityCodeType = identityCodeType;
	}
	public Timestamp getFinalizedTime() {
		return finalizedTime;
	}
	public void setFinalizedTime(Timestamp finalizedTime) {
		this.finalizedTime = finalizedTime;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public Timestamp getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}
	public String getExtendInfo() {
		return extendInfo;
	}
	public void setExtendInfo(String extendInfo) {
		this.extendInfo = extendInfo;
	}
}